const app = getApp();
const AJAX = app.$ajax,
  $wx = app.$wx;

Page({
  data: {
    imgHost: app.imgHost,
    orderStatus: {
      30: {
        text: '待退款',
        fun: ''
      },

      40: {
        text: '已退款',
        fun: ''
      },

      50: {
        text: '售后',
        fun: ''
      },
    }
  },

  onLoad(options){
    this.getOrderList({
      status: parseInt(options.type) + 1
    });
  },
  
  onShareAppMessage(){

  },
  
  refund(e){
    let ed = e.currentTarget.dataset;

    wx.navigateTo({
      url: '/pages/subpage/order/after-sale/after-sale?commodity_index=' + ed.index
    })
  },
  
  getOrderList(params = {}) {
    AJAX.orderList({
      loadType: 'bar',
      ...params
    }).then(([status, res, msg]) => {
      if (status) {
        this.setData({
          orderList: res
        });
      } else {
        $wx.showToast(msg);
      }
    });
  }
});